{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "N2IUDwhPvDD2" }, "source": [ "# 2. Prepare input data of Yoshii River\n", "*Written by Men Vuthy, 2022*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Import modules**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "executionInfo": { "elapsed": 2332, "status": "ok", "timestamp": 1647337947212, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "GUtVEQQsYOqG" }, "outputs": [], "source": [ "import os\n", "import numpy as np\n", "import pandas as pd\n", "\n", "import matplotlib.pyplot as plt\n", "\n", "import rasterio\n", "import geopandas as gpd" ] }, { "cell_type": "markdown", "metadata": { "id": "4kzODWJeteuT" }, "source": [ "**Label**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "executionInfo": { "elapsed": 533, "status": "ok", "timestamp": 1647337947742, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "0eRWOvq2YlB1" }, "outputs": [], "source": [ "yoshii_class_img = rasterio.open('data/yoshii_river/out_img/class/yoshii_class.tiff')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "executionInfo": { "elapsed": 3, "status": "ok", "timestamp": 1647337947742, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "8WuGITVVfVpR" }, "outputs": [], "source": [ "yoshii_class = yoshii_class_img.read(1).reshape(-1)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "executionInfo": { "elapsed": 3, "status": "ok", "timestamp": 1647337947742, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "34uDVmPonYvn" }, "outputs": [], "source": [ "yoshii_label = pd.DataFrame({'label':yoshii_class})" ] }, { "cell_type": "markdown", "metadata": { "id": "efyxwD0c8I8z" }, "source": [ "**Dataframe of Season 1**" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "executionInfo": { "elapsed": 2, "status": "ok", "timestamp": 1647337947742, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "dxzPDKy_fvWT" }, "outputs": [], "source": [ "season1_rgbn = rasterio.open('data/yoshii_river/out_img/rgbn/yoshii_20190409_rgbn.tiff')\n", "season1_ndvi = rasterio.open('data/yoshii_river/out_img/ndvi/yoshii_20190409_ndvi.tiff')\n", "season1_ndwi = rasterio.open('data/yoshii_river/out_img/ndwi/yoshii_20190409_ndwi.tiff')\n", "season1_bsi = rasterio.open('data/yoshii_river/out_img/bsi/yoshii_20190409_bsi.tiff')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "executionInfo": { "elapsed": 2941, "status": "ok", "timestamp": 1647337950681, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "A9aRPiqjrBjC" }, "outputs": [], "source": [ "blue_1 = season1_rgbn.read(1).reshape(-1)\n", "green_1 = season1_rgbn.read(2).reshape(-1)\n", "red_1 = season1_rgbn.read(3).reshape(-1)\n", "nir_1 = season1_rgbn.read(4).reshape(-1)\n", "\n", "ndvi_1 = season1_ndvi.read(1).reshape(-1)\n", "ndwi_1 = season1_ndwi.read(1).reshape(-1)\n", "bsi_1 = season1_bsi.read(1).reshape(-1)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "executionInfo": { "elapsed": 424, "status": "ok", "timestamp": 1647337951100, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "cKMuZhn8rJgR" }, "outputs": [], "source": [ "Season_1 = pd.DataFrame({'B1':blue_1, 'G1':green_1, 'R1':red_1, 'NIR1':nir_1, 'NDVI1':ndvi_1, 'NDWI1':ndwi_1, 'BSI1':bsi_1})" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "executionInfo": { "elapsed": 7, "status": "ok", "timestamp": 1647337951100, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "y8dt2IOysWrh", "outputId": "e4a20afc-68da-492d-9370-c313246520c8" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
B1G1R1NIR1NDVI1NDWI1BSI1
00000NaNNaNNaN
10000NaNNaNNaN
20000NaNNaNNaN
30000NaNNaNNaN
40000NaNNaNNaN
........................
382839400000NaNNaNNaN
382839410000NaNNaNNaN
382839420000NaNNaNNaN
382839430000NaNNaNNaN
382839440000NaNNaNNaN
\n", "

38283945 rows × 7 columns

\n", "
" ], "text/plain": [ " B1 G1 R1 NIR1 NDVI1 NDWI1 BSI1\n", "0 0 0 0 0 NaN NaN NaN\n", "1 0 0 0 0 NaN NaN NaN\n", "2 0 0 0 0 NaN NaN NaN\n", "3 0 0 0 0 NaN NaN NaN\n", "4 0 0 0 0 NaN NaN NaN\n", "... .. .. .. ... ... ... ...\n", "38283940 0 0 0 0 NaN NaN NaN\n", "38283941 0 0 0 0 NaN NaN NaN\n", "38283942 0 0 0 0 NaN NaN NaN\n", "38283943 0 0 0 0 NaN NaN NaN\n", "38283944 0 0 0 0 NaN NaN NaN\n", "\n", "[38283945 rows x 7 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Season_1" ] }, { "cell_type": "markdown", "metadata": { "id": "5tIbL4BkpJa2" }, "source": [ "**Dataframe of Season 2**" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "executionInfo": { "elapsed": 271, "status": "ok", "timestamp": 1647337951367, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "yYKDT-cLpJJr" }, "outputs": [], "source": [ "season2_rgbn = rasterio.open('data/yoshii_river/out_img/rgbn/yoshii_20190805_rgbn.tiff')\n", "season2_ndvi = rasterio.open('data/yoshii_river/out_img/ndvi/yoshii_20190805_ndvi.tiff')\n", "season2_ndwi = rasterio.open('data/yoshii_river/out_img/ndwi/yoshii_20190805_ndwi.tiff')\n", "season2_bsi = rasterio.open('data/yoshii_river/out_img/bsi/yoshii_20190805_bsi.tiff')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "executionInfo": { "elapsed": 3676, "status": "ok", "timestamp": 1647337955040, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "lLq3mThwpZnI" }, "outputs": [], "source": [ "blue_2 = season2_rgbn.read(1).reshape(-1)\n", "green_2 = season2_rgbn.read(2).reshape(-1)\n", "red_2 = season2_rgbn.read(3).reshape(-1)\n", "nir_2 = season2_rgbn.read(4).reshape(-1)\n", "\n", "ndvi_2 = season2_ndvi.read(1).reshape(-1)\n", "ndwi_2 = season2_ndwi.read(1).reshape(-1)\n", "bsi_2 = season2_bsi.read(1).reshape(-1)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "executionInfo": { "elapsed": 380, "status": "ok", "timestamp": 1647337955415, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "RAqkedgSpkXn" }, "outputs": [], "source": [ "Season_2 = pd.DataFrame({'B2':blue_2, 'G2':green_2, 'R2':red_2, 'NIR2':nir_2, 'NDVI2':ndvi_2, 'NDWI2':ndwi_2, 'BSI2':bsi_2})" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "executionInfo": { "elapsed": 5, "status": "ok", "timestamp": 1647337955416, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "j2Zp2QI2pru4", "outputId": "fab743f4-b152-4359-88bc-410cace9891d" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
B2G2R2NIR2NDVI2NDWI2BSI2
00000NaNNaNNaN
10000NaNNaNNaN
20000NaNNaNNaN
30000NaNNaNNaN
40000NaNNaNNaN
........................
382839400000NaNNaNNaN
382839410000NaNNaNNaN
382839420000NaNNaNNaN
382839430000NaNNaNNaN
382839440000NaNNaNNaN
\n", "

38283945 rows × 7 columns

\n", "
" ], "text/plain": [ " B2 G2 R2 NIR2 NDVI2 NDWI2 BSI2\n", "0 0 0 0 0 NaN NaN NaN\n", "1 0 0 0 0 NaN NaN NaN\n", "2 0 0 0 0 NaN NaN NaN\n", "3 0 0 0 0 NaN NaN NaN\n", "4 0 0 0 0 NaN NaN NaN\n", "... .. .. .. ... ... ... ...\n", "38283940 0 0 0 0 NaN NaN NaN\n", "38283941 0 0 0 0 NaN NaN NaN\n", "38283942 0 0 0 0 NaN NaN NaN\n", "38283943 0 0 0 0 NaN NaN NaN\n", "38283944 0 0 0 0 NaN NaN NaN\n", "\n", "[38283945 rows x 7 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Season_2" ] }, { "cell_type": "markdown", "metadata": { "id": "k_HvDVLoqCGI" }, "source": [ "**Dataframe of Season 3**" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "executionInfo": { "elapsed": 4, "status": "ok", "timestamp": 1647337955416, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "_x0caSaXptHI" }, "outputs": [], "source": [ "season3_rgbn = rasterio.open('data/yoshii_river/out_img/rgbn/yoshii_20191007_rgbn.tiff')\n", "season3_ndvi = rasterio.open('data/yoshii_river/out_img/ndvi/yoshii_20191007_ndvi.tiff')\n", "season3_ndwi = rasterio.open('data/yoshii_river/out_img/ndwi/yoshii_20191007_ndwi.tiff')\n", "season3_bsi = rasterio.open('data/yoshii_river/out_img/bsi/yoshii_20191007_bsi.tiff')" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "executionInfo": { "elapsed": 4134, "status": "ok", "timestamp": 1647337959546, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "7rdZVc-Mqige" }, "outputs": [], "source": [ "blue_3 = season3_rgbn.read(1).reshape(-1)\n", "green_3 = season3_rgbn.read(2).reshape(-1)\n", "red_3 = season3_rgbn.read(3).reshape(-1)\n", "nir_3 = season3_rgbn.read(4).reshape(-1)\n", "\n", "ndvi_3 = season3_ndvi.read(1).reshape(-1)\n", "ndwi_3 = season3_ndwi.read(1).reshape(-1)\n", "bsi_3 = season3_bsi.read(1).reshape(-1)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "executionInfo": { "elapsed": 1324, "status": "ok", "timestamp": 1647337960860, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "cUdE7Gq3qpVX" }, "outputs": [], "source": [ "Season_3 = pd.DataFrame({'B3':blue_3, 'G3':green_3, 'R3':red_3, 'NIR3':nir_3, 'NDVI3':ndvi_3, 'NDWI3':ndwi_3, 'BSI3':bsi_3})" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "executionInfo": { "elapsed": 5, "status": "ok", "timestamp": 1647337960860, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "ETLVsonaq0qo", "outputId": "a3ca1325-c6f4-4a43-8278-9ce6c2841ac7" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
B3G3R3NIR3NDVI3NDWI3BSI3
00000NaNNaNNaN
10000NaNNaNNaN
20000NaNNaNNaN
30000NaNNaNNaN
40000NaNNaNNaN
........................
382839400000NaNNaNNaN
382839410000NaNNaNNaN
382839420000NaNNaNNaN
382839430000NaNNaNNaN
382839440000NaNNaNNaN
\n", "

38283945 rows × 7 columns

\n", "
" ], "text/plain": [ " B3 G3 R3 NIR3 NDVI3 NDWI3 BSI3\n", "0 0 0 0 0 NaN NaN NaN\n", "1 0 0 0 0 NaN NaN NaN\n", "2 0 0 0 0 NaN NaN NaN\n", "3 0 0 0 0 NaN NaN NaN\n", "4 0 0 0 0 NaN NaN NaN\n", "... .. .. .. ... ... ... ...\n", "38283940 0 0 0 0 NaN NaN NaN\n", "38283941 0 0 0 0 NaN NaN NaN\n", "38283942 0 0 0 0 NaN NaN NaN\n", "38283943 0 0 0 0 NaN NaN NaN\n", "38283944 0 0 0 0 NaN NaN NaN\n", "\n", "[38283945 rows x 7 columns]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Season_3" ] }, { "cell_type": "markdown", "metadata": { "id": "S2-5njKqq-Ou" }, "source": [ "**Dataframe of Season 4**" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "executionInfo": { "elapsed": 5, "status": "ok", "timestamp": 1647337960861, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "RiTAGhkjq3T4" }, "outputs": [], "source": [ "season4_rgbn = rasterio.open('data/yoshii_river/out_img/rgbn/yoshii_20200104_rgbn.tiff')\n", "season4_ndvi = rasterio.open('data/yoshii_river/out_img/ndvi/yoshii_20200104_ndvi.tiff')\n", "season4_ndwi = rasterio.open('data/yoshii_river/out_img/ndwi/yoshii_20200104_ndwi.tiff')\n", "season4_bsi = rasterio.open('data/yoshii_river/out_img/bsi/yoshii_20200104_bsi.tiff')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "executionInfo": { "elapsed": 5373, "status": "ok", "timestamp": 1647337966229, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "7Tb5TVotrQc4" }, "outputs": [], "source": [ "blue_4 = season4_rgbn.read(1).reshape(-1)\n", "green_4 = season4_rgbn.read(2).reshape(-1)\n", "red_4 = season4_rgbn.read(3).reshape(-1)\n", "nir_4 = season4_rgbn.read(4).reshape(-1)\n", "\n", "ndvi_4 = season4_ndvi.read(1).reshape(-1)\n", "ndwi_4 = season4_ndwi.read(1).reshape(-1)\n", "bsi_4 = season4_bsi.read(1).reshape(-1)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "executionInfo": { "elapsed": 1067, "status": "ok", "timestamp": 1647337967285, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "Ly1uhXo4rXX3" }, "outputs": [], "source": [ "Season_4 = pd.DataFrame({'B4':blue_4, 'G4':green_4, 'R4':red_4, 'NIR4':nir_4, 'NDVI4':ndvi_4, 'NDWI4':ndwi_4, 'BSI4':bsi_4})" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "executionInfo": { "elapsed": 380, "status": "ok", "timestamp": 1647337967663, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "p_ivo4ZordUW", "outputId": "2f625008-73c0-4486-9aef-393a865a0d5d" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
B4G4R4NIR4NDVI4NDWI4BSI4
00000NaNNaNNaN
10000NaNNaNNaN
20000NaNNaNNaN
30000NaNNaNNaN
40000NaNNaNNaN
........................
382839400000NaNNaNNaN
382839410000NaNNaNNaN
382839420000NaNNaNNaN
382839430000NaNNaNNaN
382839440000NaNNaNNaN
\n", "

38283945 rows × 7 columns

\n", "
" ], "text/plain": [ " B4 G4 R4 NIR4 NDVI4 NDWI4 BSI4\n", "0 0 0 0 0 NaN NaN NaN\n", "1 0 0 0 0 NaN NaN NaN\n", "2 0 0 0 0 NaN NaN NaN\n", "3 0 0 0 0 NaN NaN NaN\n", "4 0 0 0 0 NaN NaN NaN\n", "... .. .. .. ... ... ... ...\n", "38283940 0 0 0 0 NaN NaN NaN\n", "38283941 0 0 0 0 NaN NaN NaN\n", "38283942 0 0 0 0 NaN NaN NaN\n", "38283943 0 0 0 0 NaN NaN NaN\n", "38283944 0 0 0 0 NaN NaN NaN\n", "\n", "[38283945 rows x 7 columns]" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Season_4" ] }, { "cell_type": "markdown", "metadata": { "id": "LhqoBmmMvczS" }, "source": [ "**Features and Label**" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "executionInfo": { "elapsed": 4323, "status": "ok", "timestamp": 1647337971981, "user": { "displayName": "MEN Vuthy", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Ggz_fgR6NAqa_UnWAIIDjX9pd1OkdeBn_u164cC=s64", "userId": "02183312642253897909" }, "user_tz": -540 }, "id": "-MMyjJRkrfjX" }, "outputs": [], "source": [ "# concat dataframe of all seasons and label into one dataframe\n", "Yoshii_dataframe = pd.concat([Season_1, Season_2, Season_3, Season_4, yoshii_label], axis=1)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "id": "z9jaUKUfv10G" }, "outputs": [], "source": [ "# Remove all rows where NDVI1 is NaN\n", "Yoshii_classified = Yoshii_dataframe.dropna(subset=['NDVI1'])" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
B1G1R1NIR1NDVI1NDWI1BSI1B2G2R2...NDWI3BSI3B4G4R4NIR4NDVI4NDWI4BSI4label
4371353558601513889-0.0230030.0810560.279785324421385...-0.0545660.2357403494894576860.135323-0.0304850.2220907
4371354558601513889-0.0230030.0810560.279785324421385...-0.0545660.2357403494894576860.135323-0.0304850.2220907
43713556146395331012-0.0060310.0470610.282591334440420...-0.1180040.2590523875405718430.127158-0.0837390.2538887
437135670571560612030.0113120.0168380.292253391507509...-0.2225980.26235045862770510270.120572-0.1075440.2736031
437135781679468114720.039086-0.0316510.304678501614648...-0.2579520.26477755773383812540.133792-0.1289880.2859781
..................................................................
3407632689688375328330.309235-0.2967010.300410473619575...-0.4823530.25391349266479514640.233941-0.2510740.2926991
3407632791990477527000.275665-0.2637210.301996484628582...-0.4646200.25374148966781814280.208541-0.2372490.2968891
3407632894992980325630.236333-0.2264340.304925523659616...-0.4246490.26384951970487513970.165456-0.2011090.3014711
3407632996495182724450.206467-0.1927170.304421559695657...-0.3518970.26871150773685914220.183002-0.1882590.2716481
34076330101098986923620.167315-0.1569900.308427615750733...-0.3189190.26963457379189715010.188206-0.1795630.2740911
\n", "

1152991 rows × 29 columns

\n", "
" ], "text/plain": [ " B1 G1 R1 NIR1 NDVI1 NDWI1 BSI1 B2 G2 R2 \\\n", "4371353 558 601 513 889 -0.023003 0.081056 0.279785 324 421 385 \n", "4371354 558 601 513 889 -0.023003 0.081056 0.279785 324 421 385 \n", "4371355 614 639 533 1012 -0.006031 0.047061 0.282591 334 440 420 \n", "4371356 705 715 606 1203 0.011312 0.016838 0.292253 391 507 509 \n", "4371357 816 794 681 1472 0.039086 -0.031651 0.304678 501 614 648 \n", "... ... ... ... ... ... ... ... ... ... ... \n", "34076326 896 883 753 2833 0.309235 -0.296701 0.300410 473 619 575 \n", "34076327 919 904 775 2700 0.275665 -0.263721 0.301996 484 628 582 \n", "34076328 949 929 803 2563 0.236333 -0.226434 0.304925 523 659 616 \n", "34076329 964 951 827 2445 0.206467 -0.192717 0.304421 559 695 657 \n", "34076330 1010 989 869 2362 0.167315 -0.156990 0.308427 615 750 733 \n", "\n", " ... NDWI3 BSI3 B4 G4 R4 NIR4 NDVI4 NDWI4 \\\n", "4371353 ... -0.054566 0.235740 349 489 457 686 0.135323 -0.030485 \n", "4371354 ... -0.054566 0.235740 349 489 457 686 0.135323 -0.030485 \n", "4371355 ... -0.118004 0.259052 387 540 571 843 0.127158 -0.083739 \n", "4371356 ... -0.222598 0.262350 458 627 705 1027 0.120572 -0.107544 \n", "4371357 ... -0.257952 0.264777 557 733 838 1254 0.133792 -0.128988 \n", "... ... ... ... ... ... ... ... ... ... \n", "34076326 ... -0.482353 0.253913 492 664 795 1464 0.233941 -0.251074 \n", "34076327 ... -0.464620 0.253741 489 667 818 1428 0.208541 -0.237249 \n", "34076328 ... -0.424649 0.263849 519 704 875 1397 0.165456 -0.201109 \n", "34076329 ... -0.351897 0.268711 507 736 859 1422 0.183002 -0.188259 \n", "34076330 ... -0.318919 0.269634 573 791 897 1501 0.188206 -0.179563 \n", "\n", " BSI4 label \n", "4371353 0.222090 7 \n", "4371354 0.222090 7 \n", "4371355 0.253888 7 \n", "4371356 0.273603 1 \n", "4371357 0.285978 1 \n", "... ... ... \n", "34076326 0.292699 1 \n", "34076327 0.296889 1 \n", "34076328 0.301471 1 \n", "34076329 0.271648 1 \n", "34076330 0.274091 1 \n", "\n", "[1152991 rows x 29 columns]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Yoshii_classified" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "id": "kfDWqViT1pRI" }, "outputs": [], "source": [ "# Data dir\n", "data_dir = \"data/yoshii_river/out_img/classified\"\n", "\n", "# Output dataframe\n", "out_df = os.path.join(data_dir, 'yoshii_classified.csv')\n", "\n", "# export dataframe to csv\n", "Yoshii_classified.to_csv(out_df, index=False)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "id": "ut1eM8opzDWU" }, "outputs": [], "source": [ "# Data dir\n", "data_dir = \"data/yoshii_river/out_img/classified\"\n", "\n", "# Output dataframe\n", "out_df = os.path.join(data_dir, 'yoshii_classified_index.csv')\n", "\n", "# export dataframe to csv\n", "Yoshii_classified.to_csv(out_df)" ] } ], "metadata": { "colab": { "authorship_tag": "ABX9TyO3G0LDfhmDKTCllN3BGQnY", "name": "6. Input Data for Supervised-ML- Yoshii River.ipynb", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.10" } }, "nbformat": 4, "nbformat_minor": 4 }